home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / comm / net / netutils.lha / NetUtilities / source / send.c < prev   
C/C++ Source or Header  |  1993-04-05  |  850b  |  50 lines

  1.  
  2. #include <stdio.h>
  3. #include <libraries/dos.h>
  4.  
  5. #define SND_PKT "net:ram/receive.pkt"
  6. #define INF_PKT "net:ram/inform.pkt"
  7. #define SND_ERR "Couldn't open send packet\n"
  8.  
  9. struct FileHandle *out=0;
  10.  
  11. void quit(void) {
  12.   Close(out);
  13.   exit(0);
  14. }
  15.  
  16. void main(void) {
  17.   char buf[256];
  18.   FILE *outfile=0;
  19.   short err=0, i;
  20.  
  21.   out = (struct FileHandle *)Open("CON:0/100/600/100/Parnet chat send",MODE_NEWFILE);
  22.  
  23.   if (!out) quit();
  24.  
  25.   if (outfile = fopen(INF_PKT, "w")) fclose(outfile);
  26.  
  27.   onbreak(quit);
  28.  
  29.   for(;;) {
  30.     chkabort();
  31.  
  32.     for (i=0;i<256;i++) buf[i]=0;
  33.     Read(out,buf,256);
  34.  
  35.     chkabort();
  36.  
  37.     err=0;
  38.     if (access(SND_PKT, 0) != 0) {
  39.       outfile=0;
  40.       if (outfile = fopen(SND_PKT, "w")) {
  41.         fputs(buf, outfile);
  42.         fclose(outfile);
  43.       } else err=1;
  44.     };
  45.  
  46.     if (err==1) Write(out, SND_ERR, strlen(SND_ERR));
  47.   }
  48. }
  49.  
  50.